home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / kernel / proc.h < prev    next >
C/C++ Source or Header  |  1990-07-15  |  4KB  |  92 lines

  1. /* Here is the declaration of the process table.  It contains the process'
  2.  * registers, memory map, accounting, and message send/receive information.
  3.  * Many assembly code routines reference fields in it.  The offsets to these
  4.  * fields are defined in the assembler include file sconst.h.  When changing
  5.  * 'proc', be sure to change sconst.h to match.
  6.  */
  7.  
  8. struct proc {
  9.   struct stackframe_s p_reg;    /* process' registers saved in stack frame */
  10.  
  11. #if (CHIP == INTEL)
  12.   reg_t p_ldt_sel;        /* selector in gdt giving ldt base and limit*/
  13.   struct segdesc_s p_ldt[2];    /* local descriptors for code and data */
  14.                 /* 2 is LDT_SIZE - avoid include protect.h */
  15.   reg_t p_splimit;        /* lowest legal stack value */
  16. #endif /* (CHIP == INTEL) */
  17.  
  18. #if (CHIP == M68000)
  19.   reg_t p_splow;        /* lowest observed stack value */
  20.   int p_trap;            /* trap type (only low byte) */
  21.   phys_clicks p_shadow;        /* set if shadowed process image */
  22.   int p_nflips;            /* statistics */
  23.   char p_physio;        /* cannot be (un)shadowed now if set */
  24.                 /* there will be a gap here!! ++jrb */
  25. #endif /* (CHIP == M68000) */
  26.  
  27.   int p_nr;            /* number of this process (for fast access) */
  28.  
  29.   int p_int_blocked;        /* nonzero if int msg blocked by busy task */
  30.   int p_int_held;        /* nonzero if int msg held by busy syscall */
  31.   struct proc *p_nextheld;    /* next in chain of held-up int processes */
  32.  
  33.   int p_flags;            /* P_SLOT_FREE, SENDING, RECEIVING, etc. */
  34.   struct mem_map p_map[NR_SEGS];/* memory map */
  35.   int p_pid;            /* process id passed in from MM */
  36.  
  37.   time_t user_time;        /* user time in ticks */
  38.   time_t sys_time;        /* sys time in ticks */
  39.   time_t child_utime;        /* cumulative user time of children */
  40.   time_t child_stime;        /* cumulative sys time of children */
  41.   time_t p_alarm;        /* time of next alarm in ticks, or 0 */
  42.  
  43.   struct proc *p_callerq;    /* head of list of procs wishing to send */
  44.   struct proc *p_sendlink;    /* link to next proc wishing to send */
  45.   message *p_messbuf;        /* pointer to message buffer */
  46.   int p_getfrom;        /* from whom does process want to receive? */
  47.  
  48.   struct proc *p_nextready;    /* pointer to next ready process */
  49.   int p_pending;        /* bit map for pending signals 1-16 */
  50.   unsigned p_pendcount;        /* count of pending and unfinished signals */
  51. };
  52.  
  53. /* Bits for p_flags in proc[].  A process is runnable iff p_flags == 0. */
  54. #define P_SLOT_FREE      001    /* set when slot is not in use */
  55. #define NO_MAP           002    /* keeps unmapped forked child from running */
  56. #define SENDING          004    /* set when process blocked trying to send */
  57. #define RECEIVING        010    /* set when process blocked trying to recv */
  58. #define PENDING          020    /* set when inform() of signal pending */
  59. #define SIG_PENDING      040    /* keeps to-be-signalled proc from running */
  60. #define P_STOP        0100    /* set when process is being traced */
  61.  
  62. /* Magic process table addresses. */
  63. #define BEG_PROC_ADDR (&proc[0])
  64. #define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
  65. #define END_TASK_ADDR (&proc[NR_TASKS])
  66. #define BEG_SERV_ADDR (&proc[NR_TASKS])
  67. #define BEG_USER_ADDR (&proc[NR_TASKS + LOW_USER])
  68.  
  69. #define NIL_PROC          ((struct proc *) 0)
  70. #define isidlehardware(n) ((n) == IDLE || (n) == HARDWARE)
  71. #define isokprocn(n)      ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
  72. #define isoksrc_dest(n)   (isokprocn(n) || (n) == ANY)
  73. #define isoksusern(n)     ((unsigned) (n) < NR_PROCS)
  74. #define isokusern(n)      ((unsigned) ((n) - LOW_USER) < NR_PROCS - LOW_USER)
  75. #define isrxhardware(n)   ((n) == ANY || (n) == HARDWARE)
  76. #define isservn(n)        ((unsigned) (n) < LOW_USER)
  77. #define istaskp(p)        ((p) < END_TASK_ADDR && (p) != cproc_addr(IDLE))
  78. #define isuserp(p)        ((p) >= BEG_USER_ADDR)
  79. #define proc_addr(n)      (pproc_addr + NR_TASKS)[(n)]
  80. #define cproc_addr(n)     (&(proc + NR_TASKS)[(n)])
  81. #define proc_number(p)    ((p)->p_nr)
  82. #if (CHIP == M68000)
  83. #define isshadowp(p)      ((p)->p_shadow)
  84. #endif
  85.  
  86. EXTERN struct proc proc[NR_TASKS + NR_PROCS];    /* process table */
  87. EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
  88.                 /* ptrs to process table slots (fast) */
  89. EXTERN struct proc *bill_ptr;    /* ptr to process to bill for clock ticks */
  90. EXTERN struct proc *rdy_head[NQ];    /* pointers to ready list headers */
  91. EXTERN struct proc *rdy_tail[NQ];    /* pointers to ready list tails */
  92.